<template>
  <div class="crumb">
    <el-breadcrumb separator-icon="ArrowRight">
      <template v-for="(item, i) in breadcrumbs" :key="i">
        <el-breadcrumb-item :to="item.path">{{ item.name }}</el-breadcrumb-item>
      </template>
    </el-breadcrumb>
  </div>
</template>
<script setup lang="ts">
import useLoginStore from '@/store/login/login'
import { mapMenusToBreadcrumbs } from '@/utils/map-menus'
import { computed } from 'vue'
// import { watch } from 'vue'
import { useRoute } from 'vue-router'
// setup只执行一次 watch 路径发生改变，再次执行或者计算属性
// 1，获取动态菜单
const LoginStore = useLoginStore()
const userMenus = LoginStore.userMenus
const route = useRoute()
const breadcrumbs = computed(() => {
  return mapMenusToBreadcrumbs(route.path, userMenus)
})
</script>
<style lang="less" scoped>
.crumb {
  color: red;
}
</style>
